import { createApp } from 'vue';
import App from './App.vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import router from './router';
import axios from 'axios';

const app = createApp(App);

// 设置 Axios 的默认基准 URL
axios.defaults.baseURL = 'http://localhost:8090';

// 配置 Axios 拦截器
axios.interceptors.request.use(config => {
    const token = localStorage.getItem('token');
    if (token) {
        config.headers.Authorization = `Bearer ${token}`;
    }
    return config;
}, error => {
    return Promise.reject(error);
});

app.use(ElementPlus);
app.use(router);
app.mount('#app');
